package com.laiketui.admin.store.controller;


import com.laiketui.admin.store.api.generalProperty.GeneralPropertyService;
import com.laiketui.core.domain.Result;
import com.laiketui.core.exception.LaiKeAPIException;
import com.laiketui.domain.generalProperty.GeneralProperty;
import com.laiketui.root.annotation.HttpApiMethod;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "一般属性")
@RestController
@RequestMapping("/admin/generalProperty")
public class GeneralPropertyController {
    @Autowired
    private GeneralPropertyService generalPropertyService;

    @ApiOperation("一般属性列表")
    @PostMapping("/list")
    @HttpApiMethod(apiKey = "admin.generalProperty.list")
    public Result list(GeneralProperty generalProperty) {
        try {
            return Result.success(generalPropertyService.selectPropertyByCategories(generalProperty));
        } catch (LaiKeAPIException e) {
            return Result.error(e.getCode(), e.getMessage());
        }
    }
}
